package com.cysion.study.ui.personal

import android.view.View
import com.cysion.study.ktbox.base.BaseActivity
import com.cysion.study.ktbox.utils.whiteTextTheme
import com.cysion.other.color
import com.cysion.study.uibox.bar.TopBar
import com.cysion.study.R
import com.cysion.study.helper.UserCache
import com.cysion.study.ktbox.Box.context
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.study.net.ApiClient
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.widget.ShowToast
import com.cysion.study.widget.VersionUtil
import com.cysion.targetfun._subscribe
import kotlinx.android.synthetic.main.activity_about.*
import kotlinx.android.synthetic.main.fragment_teacher1.*

/**
 * Created by chu on 2019-07-01.
 */
class AboutActivity:BaseActivity()  {


    override fun getLayoutId(): Int = R.layout.activity_about

    override fun initView() {
        whiteTextTheme(color(R.color.main_cl))
        topbar.apply {
            setTitle("关于我们")
            setOnTopBarClickListener { obj, pos ->
                if (pos == TopBar.Pos.LEFT) {
                    finish()
                }
            }
        }
        tv_version.text = "V "+ VersionUtil.getAppVersionName()
        getDataList()

    }

    private fun getDataList() {
        Alert.loading(this)
        //type：1、家长端关于介绍；2、教师端关于介绍 3.家长端用户协议 4.家长端隐私政策 5.普教端用户协议 6.普教端隐私政策
        ApiClient.api.getAboutInfo("2",UserCache.token).compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()

                    var content= it.content
                    wb_content.loadDataWithBaseURL(null,content, "text/html", "UTF-8", null)

                }
                _onError {
                    Alert.close()

                    ShowToast(ErrorHandler.handle(it).errorMsg)
                }
            }
    }



    override fun closeMvp() {
    }
}